package com.dunqi.gpm.shunqing.home.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.dunqi.gpm.shunqing.R;
import com.dunqi.gpm.shunqing.common.base.BaseAct;
import com.dunqi.gpm.shunqing.common.view.ComTitleBar;
import com.dunqi.gpm.shunqing.home.constance.Constance;
import com.dunqi.gpm.shunqing.home.fragment.HomeFragment;
import com.dunqi.gpm.shunqing.home.fragment.ProjectWorkTrendFragment;
import com.dunqi.gpm.shunqing.my.util.UserUtil;

import java.util.HashMap;

import butterknife.BindView;
import butterknife.OnClick;

public class ProjectTrendActivity extends BaseAct {


    private static final String AUDIT_STATUSS = "audit_statuss";
    @BindView(R.id.title_bar)
    ComTitleBar titleBar;
    @BindView(R.id.edit_tv)
    TextView editTv;
    HashMap<String, String> hashMap = new HashMap<>();
    private ProjectWorkTrendFragment fragment;

    @Override
    protected void refreshData(Bundle savedInstanceState) {


    }

    @Override
    protected void initUiAndListener() {
        String audit_statuss = getIntent().getStringExtra(AUDIT_STATUSS);
//        hashMap.put("audit_status", audit_statuss);
        fragment = ProjectWorkTrendFragment.newInstance(hashMap);
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, fragment)
                .commit();

        if (UserUtil.userFromNdrcOrg() && !UserUtil.userIsLeader() && HomeFragment.homeMenuId== Constance.MENU_WORK_TREND) {
            editTv.setVisibility(View.VISIBLE);
        } else {
            editTv.setVisibility(View.GONE);
        }

        if (HomeFragment.homeMenuId== Constance.MENU_DYNAMIC_APPROVAL)
            titleBar.setTitle("动态审核列表");

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        fragment.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_project_trend;
    }

    @OnClick(R.id.edit_tv)
    public void onViewClicked() {
        addOne();
    }

    public static void start(Context context, String audit_statuss) {
        Intent intent = new Intent(context, ProjectTrendActivity.class);
        intent.putExtra(AUDIT_STATUSS, audit_statuss);
        context.startActivity(intent);
    }

    private void addOne() {
        CreateProjectTrendActivity.start(this, -1l,null,new HashMap<String, String>());
    }
}
